package evi.com.evi.utils;

import android.app.Activity;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import static android.content.Context.CONNECTIVITY_SERVICE;

/**
 * Created by sunyu on 2017/5/11.
 */

public class ConnectUtil {

    public static final boolean isConnect(Activity activity) {
        ConnectivityManager connectivityManager = (ConnectivityManager) activity.getSystemService(CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        if (networkInfo == null || !networkInfo.isAvailable()) {
            //当前无可用网络

            return false;
        } else {
            //当前有可用网络
            return true;
        }
    }
}
